package com.han.nettytestdemo.connector.communication;

/**
 * Created by bayi on 2016/2/26.
 */
public class OrderManage {

    private OrderStorage orderStorage;
    private static OrderManage orderManage;

    //命令缓存池
    public OrderManage() {
        this.orderStorage = OrderStorage.getInstance();
    }

    public static OrderManage getInstance() {
        return orderManage = orderManage == null ? new OrderManage() : orderManage;
    }

    /**
     * @param msg             交互数据
     * @param productCallback 返回值
     * @param executiveLevel  线程优先级
     * @throws InterruptedException
     */
    public void putStorage(String[][] msg, ProductCallback productCallback, Order.ExecutiveLevel executiveLevel) throws InterruptedException {
        Order order = new Order(msg, productCallback, executiveLevel);
        orderStorage.putOrder(order);
    }

    public void putStorage(String[][] msg, ProductCallback productCallback, Order.ExecutiveLevel executiveLevel, ProtocolType protocolType) throws InterruptedException {
        Order order = new Order(msg, productCallback, executiveLevel, protocolType);
        orderStorage.putOrder(order);
    }

}
